home *** CD-ROM | disk | FTP | other *** search
- function CollisionDetection(striking, struck)
- {
- if(_root[striking].onFloor == _root[struck].onFloor)
- {
- if(_root[striking].direction == "left")
- {
- distance = _root[striking + "Bounds"].xMin - _root[struck + "Bounds"].xMax;
- }
- else
- {
- distance = _root[struck + "Bounds"].xMin - _root[striking + "Bounds"].xMax;
- }
- if(_root[striking].direction == _root[struck].direction)
- {
- outerreach = _root[striking].outerreach + 5;
- innerreach = _root[striking].innerreach + 5;
- }
- else
- {
- outerreach = _root[striking].outerreach;
- innerreach = _root[striking].innerreach;
- }
- if(innerreach < distance && distance < outerreach)
- {
- contact = 1;
- }
- else
- {
- contact = 0;
- }
- if(_root[striking].direction == _root[struck].direction && contact)
- {
- if(_root[struck].direction == "left")
- {
- _root[struck].direction = "right";
- }
- else
- {
- _root[struck].direction = "left";
- }
- }
- }
- else
- {
- contact = 0;
- }
- return contact;
- }
- stop();
-